package com.panopset.security;

/**
 * Encryption algorithm salt.
 *
 * @author Karl Dinwiddie
 *
 */
public final class Salt {

    /**
     * Creates a Salt with the default value.
     */
    public Salt() {
        this(DEFAULT_VALUE);
    }

    /**
     * Creates a Salt with the given value.
     * @param eightBytes Eight byte salt value.
     */
    public Salt(final byte[] eightBytes) {
        this.value = eightBytes;
    }

    /**
     * Default value.
     */
    private static final byte[] DEFAULT_VALUE = {(byte) 0xA9, (byte) 0x9B,
            (byte) 0xC8, (byte) 0x32, (byte) 0x56, (byte) 0x35, (byte) 0xE3,
            (byte) 0x03};

    /**
     * Salt value.
     */
    private byte[] value;


    /**
     *
     * @return Eight byte salt value.
     */
    public byte[] getValue() {
        if (value == null) {
            value = DEFAULT_VALUE;
        }
        return value;
    }

    /**
     * Set salt value.
     * @param salt byte value.
     */
    public void setValue(final byte[] salt) {
        value = salt;
    }
}
